package cn.bugstack.domain.strategy.model.entity;

import cn.bugstack.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * @author Lenovo
 * @version 1.0
 * @description: 策略实体
 * @date 2025/4/27 20:35
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyEntity {
    private Long strategyId;
    private String strategyDesc;
    private String ruleModels;

    public String[] ruleModels() {
       if (StringUtils.isBlank(ruleModels)) {return  null;}
       return ruleModels.split(Constants.SPLIT);
    }

    public String getRuleWeight() {
        String[] ruleModels = this.ruleModels();
        if (ruleModels == null || ruleModels.length == 0) {
            return null;
        }
        for (String ruleModel : ruleModels) {
            if ("rule_weight".equals(ruleModel)) {
                return  ruleModel;
            }
        }
        return  null;
    }
}
